package com.easyUploader.assembler;

import com.easyUploader.entity.dao.Bucket;
import com.easyUploader.entity.dto.BucketDto;
import com.easyUploader.property.LocalFileProperty;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;

import static com.easyUploader.factory.BucketFactory.BUCKET_CONVERTER;

/**
 * @author 大忽悠
 * @create 2022/11/1 14:12
 */
@RequiredArgsConstructor
@Component
public class BucketAssembler {
    private final LocalFileProperty localFileProperty;

    public List<BucketDto> assembler(List<Bucket> bucketList){
        List<BucketDto> bucketDtos = BUCKET_CONVERTER.toListBucketDto(bucketList);
        bucketDtos.forEach(bucketDto->bucketDto.buildFileInfo(localFileProperty));
        return bucketDtos;
    }
}
